<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>hello react</title>
</head>
<body>
  <div id="app"></div>
  <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
  <!-- 生产环境中不建议使用 -->
  <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
  <script type="text/babel">
    class Weather extends React.Component {
      constructor(props) {
        super(props)
        this.state = {
          isHot: false
        }
        // 绑定回调函数的方法
        this.hangleClick = this.hangleClick.bind(this)
      }
      render() {
        const { isHot } =  this.state
        return <h1 onClick={this.hangleClick}>今天天气很{ isHot ? '炎热' : '凉爽' }</h1>
      }
      hangleClick() {
        // 使用setState改变状态值
        this.setState({ isHot: !this.state.isHot})
      }
    }
    ReactDOM.render(<Weather />, document.getElementById('app'))
  </script>
</body>
</html>